<?php

namespace Kateba\GOOBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;

/**
 * Kateba\GOOBundle\Entity\StudyField
 *
 * @UniqueEntity(fields={"name"})
 * @ORM\Table(name="study_field")
 * @ORM\Entity
 */
class StudyField {

    /**
     * @var integer $id
     *
     * @ORM\Column(name="id", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    private $id;

    /**
     * the projects of this study field
     * @var \Doctrine\Common\Collections\ArrayCollection $projects
     * @ORM\OneToMany(targetEntity="\Kateba\GOOBundle\Entity\Project", mappedBy="studyField", cascade={"persist", "remove"}, orphanRemoval=true)
     */
    private $projects;

    /**
     * the calls of this study field
     * @var \Doctrine\Common\Collections\ArrayCollection $calls
     * @ORM\OneToMany(targetEntity="\Kateba\GOOBundle\Entity\Call", mappedBy="studyField", cascade={"persist", "remove"}, orphanRemoval=true)
     */
    private $calls;

    /**
     * @var string $name
     * @Assert\NotNull
     * @ORM\Column(name="name", type="string", length=255, unique=true)
     */
    private $name;

    /**
     * Get id
     *
     * @return integer 
     */
    public function getId() {
        return $this->id;
    }

    /**
     * Set name
     *
     * @param string $name
     */
    public function setName($name) {
        $this->name = $name;
    }

    /**
     * Get name
     *
     * @return string 
     */
    public function getName() {
        return $this->name;
    }

    public function __construct() {
        $this->projects = new \Doctrine\Common\Collections\ArrayCollection();
        $this->calls = new \Doctrine\Common\Collections\ArrayCollection();
    }

    public function __toString() {
        return $this->name;
    }

    /**
     * Add projects
     *
     * @param Kateba\GOOBundle\Entity\Project $projects
     */
    public function addProject(\Kateba\GOOBundle\Entity\Project $projects) {
        $this->projects[] = $projects;
    }

    /**
     * Get projects
     *
     * @return Doctrine\Common\Collections\Collection 
     */
    public function getProjects() {
        return $this->projects;
    }

    /**
     * Add calls
     *
     * @param Kateba\GOOBundle\Entity\Call $calls
     */
    public function addCall(\Kateba\GOOBundle\Entity\Call $calls) {
        $this->calls[] = $calls;
    }

    /**
     * Get calls
     *
     * @return Doctrine\Common\Collections\Collection 
     */
    public function getCalls() {
        return $this->calls;
    }

}